# 将 .c文件 属性设置为 CXX
set_source_files_properties(useHello.c hello.c PROPERTIES LANGUAGE CXX)
# 编译可执行文件 sayhello
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src)
SET(SRC_LIST useHello.c hello.c)
ADD_EXECUTABLE(sayhello ${SRC_LIST})

SET(LIBHELLO_SRC hello)
# 生成动态库
ADD_LIBRARY(hello SHARED ${LIBHELLO_SRC})
SET_TARGET_PROPERTIES(hello PROPERTIES CLEAN_DIRECT_OUTPUT 1)
# 生成静态库
ADD_LIBRARY(hello_static STATIC ${LIBHELLO_SRC})
SET_TARGET_PROPERTIES(hello_static PROPERTIES OUTPUT_NAME "hello")
MESSAGE(STATUS "This is the hello_static OUTPUT_NAME: " ${OUTPUT_NAME})

# 安装共享库和头文件
INSTALL(TARGETS hello hello_static
    LIBRARY DESTINATION /usr/local/lib
    ARCHIVE DESTINATION /usr/local/lib)

INSTALL(FILES hello.h DESTINATION /usr/local/include)

